home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / Neptune / neptune.b next >
Text File  |  1995-03-06  |  13KB  |  367 lines

  1. {*******************************************************************}
  2. { Voyage to Neptune                                                 }
  3. { For ACE basic                                                     }
  4. { This source is public domain.  Mangle it all you want.            }
  5. { Take note of these simple rules:                                  }
  6. { 1. Seek truth.  Get your hands dirty and figure it out.  Don't    }
  7. {    let anyone stop you in this pursuit.                           }
  8. { 2. Information wants to be free.  Those who share information     }
  9. {    give the universe life.  Those who keep information enslave    }
  10. {    themselves and others.                                         }
  11. { 3. Question authority.  Each mind must make itself.  Beware of    }
  12. {    those building a golden path, for it probably leads to hell.   }
  13. { 4. Judge all things by their their important attributes in        }
  14. {    context.  And check your premises.                             }
  15. { 5. Everything you create is art, good or bad.                     }
  16. { 6. Pursue happiness and when you have it, invest it in others.    }
  17. {*******************************************************************}
  18.  
  19.  
  20. dim STRING Plan(7)
  21. dim SHORTINT Trip_Distance(7)
  22. LONGINT Efficiency, Fuel_Produced, Storage_Decay, Fuel_Used, Rate
  23. LONGINT Total_Time, Used_Breeders, Distance, Temp_Input, Active_Breeders
  24. SHORTINT Flag, Answer_Num, Days, Months, Years, Segment
  25. SHORTINT Menu_Num, Selection_Num, Activated_Gadget, Counter
  26. STRING Answer_String SIZE 10
  27. STRING Temp_String SIZE 40
  28. SINGLE Malfunction, My_Time, Temp_Time, Fuel_Decay
  29.  
  30. WINDOW 9,"Voyage to Neptune",(0,0)-(637,195),22
  31. {* RENDER GADGETS, BEVEL-BOXES AND TEXT *}
  32. GADGET 255,ON,"Buy Cells",(2,166)-(109,180),BUTTON
  33. GADGET 254,ON,"Buy Fuel",(2,149)-(109,163),BUTTON
  34. GADGET 253,ON,120,(111,166)-(288,179),POTX
  35. GADGET 252,ON,3000,(111,149)-(288,162),POTX
  36. BEVELBOX (2,2)-(626,144),1
  37. GADGET 251,ON,"Make Trip",(417,149)-(520,180),BUTTON
  38. GADGET 250,ON,"Quit",(523,149)-(627,163),BUTTON
  39. GADGET 249,ON,"About",(523,166)-(627,180),BUTTON
  40.  
  41. { Set initial values }
  42. Breeders = 120
  43. Total_Fuel = 3000
  44. Segment = 1
  45. for i = 1 to 7
  46. read Plan(I), Trip_Distance(I)
  47. next i
  48. data "Earth",391,"Callisto",403,"Titan",446,"Alpha 1",447
  49. data "Ariel",507,"Theta 2",507,"Neptune",0
  50.  
  51. RANDOMIZE TIMER
  52.  
  53. Trade = int(150+(80*RND(1)))
  54.  
  55. while -1
  56.      if Segment = 7 goto ARRIVAL
  57.      gosub CONDITIONS
  58.      locate 20,37
  59.      PRINT "          ";
  60.      locate 20,37
  61.      PRINT Fuel_Used "Fuel";
  62.      locate 22,37
  63.      PRINT "          ";
  64.      locate 22,37
  65.      PRINT Active_Breeders "Cells";
  66.      GADGET WAIT 0
  67.      Activated_Gadget = GADGET(1)
  68.      CASE
  69.           Activated_Gadget = 255: gosub BUY_CELLS
  70.           Activated_Gadget = 254: gosub BUY_FUEL
  71.           Activated_Gadget = 253: gosub SET_CELLS
  72.           Activated_Gadget = 252: gosub SET_FUEL
  73.           Activated_Gadget = 251: gosub MAKE_TRIP
  74.           Activated_Gadget = 250: gosub QUIT_PROGRAM
  75.           Activated_Gadget = 249: gosub ABOUT
  76.      END CASE
  77. wend
  78.  
  79. {*********************************************************}
  80. { Subroutines                                             }
  81. {*********************************************************}
  82.  
  83. BUY_CELLS:
  84.      if (Total_Fuel - Fuel_Used) < Trade then
  85.           MsgBox "Not enough unused fuel to sell!", "OK"
  86.           return
  87.      end if
  88.      if (Total_Fuel - Trade) < 1500 then
  89.           MsgBox "Dangerously low fuel level!", "OK"
  90.           return
  91.      end if
  92.      Total_Fuel = Total_Fuel - Trade
  93.      GADGET MOD 252, Fuel_Used, Total_Fuel
  94.      ++Breeders
  95.      GADGET MOD 253, Active_Breeders, Breeders
  96.      return
  97. BUY_FUEL:
  98.      if Breeders > 50 then
  99.           --Breeders
  100.           GADGET MOD 253, Active_Breeders, Breeders
  101.           Total_Fuel = Total_Fuel + Trade
  102.           GADGET MOD 252, Fuel_Used, Total_Fuel
  103.      else
  104.           MsgBox "Need 50 breeders to stay operational!", "OK"
  105.      end if
  106.      return
  107. SET_CELLS:
  108.      Temp_Input = GADGET(3)
  109.      if Fuel_Used/20 < Temp_Input then 
  110.           MsgBox "Not enough spent fuel to run breeders!", "OK"
  111.           GADGET MOD 253, Active_Breeders, Breeders
  112.           return
  113.      end if
  114.      if Temp_Input*5 > (Total_Fuel - Fuel_Used) then
  115.           MsgBox "Not enough unused fuel to seed breeders!", "OK"
  116.           GADGET MOD 253, Active_Breeders, Breeders
  117.           return
  118.      end if
  119.      Active_Breeders = Temp_Input
  120.      return
  121. SET_FUEL:
  122.      Temp_Input = GADGET(3)
  123.      if Temp_Input > Total_Fuel then
  124.           MsgBox "Not enough fuel to fill request!", "OK"
  125.           Fuel_Used = Total_Fuel
  126.           GADGET MOD 252, Fuel_Used, Total_Fuel
  127.           return
  128.      end if
  129.      if Temp_Input/20 < Active_Breeders then 
  130.           MsgBox "Not enough spent fuel to run breeders!", "OK"
  131.           GADGET MOD 252, Fuel_Used, Total_Fuel
  132.           return
  133.      end if
  134.      if Active_Breeders*5 > (Total_Fuel - Temp_Input) then
  135.           MsgBox "Not enough unused fuel to seed breeders!", "OK"
  136.           GADGET MOD 252, Fuel_Used, Total_Fuel
  137.           return
  138.      end if
  139.      Fuel_Used = Temp_Input
  140.      return
  141. MAKE_TRIP:
  142.      { Calculate the results of input data }
  143.      Total_Fuel = Total_Fuel - Fuel_Used
  144.      Total_Fuel = Total_Fuel - 5*Active_Breeders
  145.      Efficiency = 56 - Segment*8 + Fuel_Used/40
  146.      if Efficiency>104 then Efficiency = 104 : ' 104 is max efficiency
  147.      Malfunction = RND(1)
  148.      { 10% chance of engine problem }
  149.      if Malfunction < 0.1 then
  150.           MsgBox "Engine Malfunction!", "OK"
  151.           Efficiency = Efficiency*(1-3*Malfunction)
  152.      end if
  153.      Rate = Efficiency*513.89 : 'Rate in mph
  154.      Distance = Distance + Trip_Distance(Segment) : 'Distance in million miles
  155.      My_Time = int(Trip_Distance(Segment)*41667!/Rate) : 'Time in days
  156.      Total_Time = Total_Time + My_Time : 'total trip time
  157.      Fuel_Produced = int(16+18*RND(1))
  158.      Total_Fuel = Total_Fuel + Fuel_Produced*Active_Breeders : 'New Fuel from breeder
  159.      Fuel_Decay = RND(1)
  160.      if Fuel_Decay < 0.2 then Storage_Decay = int(Fuel_Decay*Total_Fuel) : ' How much fuel decayed
  161.      Total_Fuel = Total_Fuel - Storage_Decay : ' Decrease fuel by amount that decayed
  162.      ++Segment
  163.      Fuel_Used = 0
  164.      GADGET MOD 252, 0, Total_Fuel
  165.      Used_Breeders = Active_Breeders
  166.      Active_Breeders = 0
  167.      GADGET MOD 253, 0, Breeders
  168.      Trade = int(150+(80*RND(1)))
  169.      return
  170.  
  171.  
  172. { Print current conditions }
  173. CONDITIONS:
  174.      { clear out the screen }
  175.      FOR i=2 to 17
  176.           locate i,2
  177.           print"                                       ";
  178.           print"                                      "
  179.      NEXT i
  180.  
  181.      locate 2,2
  182.      print "Location: " Plan(Segment)
  183.      locate 3,2
  184.      print "Distance to Neptune:" 2701-Distance "million miles."
  185.      if Segment > 1 then
  186.           locate 4,2
  187.           print "Distance from Earth:" Distance "million miles."
  188.           locate 5,2
  189.           print "Over the last segment, your average speed was" int(Rate) "mph,"
  190.           locate 6,2
  191.           print "and you covered" Trip_Distance(Segment - 1) "million miles in" My_Time "days."
  192.           Temp_Time = 0.81 * Distance
  193.           locate 7,2
  194.           print "Time estimate for this total distance.";
  195.           gosub CALC_TIME
  196.           Temp_Time = Total_Time
  197.           locate 8,2
  198.           print "Your actual cumulative time was:";
  199.           gosub CALC_TIME
  200.           locate 9,2
  201.           print "You used" Used_Breeders "cells which produced" Fuel_Produced "pounds of fuel each."
  202.           locate 15,2
  203.           print "Your engine worked at" Efficiency "% efficiency last trip."
  204.           if Storage_Decay > 0 then
  205.                locate 10,2 
  206.                print Storage_Decay "pounds of fuel in storage decayed into an unusable state."
  207.           end if
  208.      end if
  209.      locate 11,2
  210.      print "Pounds of nuclear fuel ready for use:" Total_Fuel
  211.      locate 12,2
  212.      print "Operational breeder-reactor cells:" Breeders
  213.      print
  214.      locate 14,2
  215.      print "Solar collectors can fulfill"; 
  216.      print  56 - Segment*8 "% of the fuel requirements of the engines."
  217.      locate 17,2
  218.      print "Breeders are trading for " Trade " pounds of fuel."
  219.      return
  220.  
  221. { calculate and print time in years }
  222. CALC_TIME:
  223.      Years = int(Temp_Time/365)
  224.      if Years >= 1 then
  225.           if Years = 1 then
  226.                print " 1 year";
  227.           else
  228.                print Years "years";
  229.           end if
  230.      end if
  231.      Months = int((Temp_Time/365-Years)*12)
  232.      if Months >= 1 then
  233.           if Months = 1 then
  234.                print ", 1 month";
  235.           else
  236.                print "," Months "months";
  237.           end if
  238.      end if
  239.      Days = int(Temp_Time-Years*365 - Months*30.5)
  240.      if Days < 1 then
  241.           print "."
  242.           return
  243.      end if
  244.      if Days = 1 then
  245.           print ", 1 day."
  246.      else
  247.           print "," Days "days."
  248.      end if
  249.      return
  250.      
  251. {************************}
  252. { Print a line, centered }
  253. {************************}
  254. CENTER_LINE:
  255.      print tab((79 - len(Temp_String))/2) Temp_String;
  256.      return
  257.  
  258. {********************}
  259. { ARRIVED AT NEPTUNE }
  260. {********************}
  261. ARRIVAL:
  262.      { clear out the screen }
  263.      FOR i=2 to 17
  264.           locate i,2
  265.           print"                                       ";
  266.           print"                                      "
  267.      NEXT i
  268.      locate 2,2
  269.      print "You finally reached Neptune in";
  270.      Temp_Time = Total_Time
  271.      gosub CALC_TIME
  272.      locate 3,2
  273.      print "Had your engines run at 100% efficiency the entire way,";
  274.      print " you would have"
  275.      locate 4,2
  276.      print "averaged 51,389 mph and completed the trip in exactly 6 years."
  277.      locate 6,2
  278.      if Temp_Time<=2220 then
  279.           Temp_String="Congratulations!  Outstanding job!"
  280.           gosub CENTER_LINE
  281.      else
  282.           Temp_Time = Total_Time - 2190
  283.           print "You trip took longer than this by";
  284.           gosub CALC_TIME
  285.           locate 7,2
  286.           print "Your performance was ";
  287.           Years = Years + 1
  288.           if Years = 1 then
  289.                print "excellent (room for slight improvement)."
  290.           else
  291.                if Years = 2 then
  292.                     print "quite good (but could be better)."
  293.                else
  294.                     if Years = 3 then
  295.                          print "marginal (could do much better)."
  296.                     else
  297.                          print "abysmal (need lots more practice)."
  298.                     end if
  299.                end if
  300.           end if
  301.      end if
  302.  
  303.      locate 9,2
  304.      if Breeders >= 105 then
  305.           print "Fortunately you have" Breeders "operational breeder-reactor cells"
  306.           locate 10,2
  307.           print "for your return trip.  Very good."
  308.      else
  309.           print "I guess you realize that the return trip will be extremely"
  310.           locate 10,2
  311.           print "chancy with only" Breeders "breeder-reactor cells operational."
  312.      end if
  313.  
  314.      locate 12,2
  315.      print "With your remaining" Total_Fuel "pounds of fuel and" Breeders "breeder"
  316.      Temp_Time = 42250!/(8+Total_Fuel/40)
  317.      if Temp_Time < 405 then Temp_Time = 405
  318.      locate 13,2
  319.      print "cells, to get back to Theta 2 will take";
  320.      gosub CALC_TIME
  321.      GADGET WAIT 0
  322.      goto QUIT_PROGRAM
  323.  
  324.  
  325. ABOUT:
  326.      WINDOW 8,,(0,0)-(640,200),0
  327.      {* RENDER GADGETS, BEVEL-BOXES AND TEXT *}
  328.      GADGET 1,ON,"Very Interesting!",(230,174)-(410,194),BUTTON
  329.      locate 1,1
  330.      print"     Voyage to Neptune is inspired by a program by the same name by David Ahl,"
  331.      print"who wrote lots of books with programs in them in the seventies and eighties."
  332.      print"He also started the magazine Creative Computing many years ago."
  333.      print"     The source to his version of this program is in his book, BASIC Computer"
  334.      print"adventures.  The algorithms are mostly the same, but if you get the chance"
  335.      print"to compare the sources you will find significant differences.  Hopefully"
  336.      print"enough to avoid any silly copyright concerns."
  337.      print"     The story behind the game is that you are piloting a space ship in 2100,"
  338.      print"making the first trip to Neptune.  Mankind has established space stations"
  339.      print"past Uranus and other places in between, however.  So, you will get the"
  340.      print"chance to stop for re-fueling."
  341.      print"     Your ship has two sources of propulsion: solar panels and nuclear rockets."
  342.      print"In addition, you have a multi-celled nuclear breeder reactor which is a tiny"
  343.      print"fusion engine.  It will take used fuel and some unused fuel to create more fuel."
  344.      print"     I'm releasing this program and its source to the public domain.  That"
  345.      print"means anyone can do whatever they want with it.  The source is for ACE basic,"
  346.      print"but it probably isn't much to get it working in AMOS.  You could add lots of"
  347.      print"other routines and make it more fun.  My email address is lda@netcom.com if"
  348.      print"anyone needs to contact me."
  349.  
  350.  
  351.  
  352.      {* GADGET HANDLING CODE STARTS HERE *}
  353.      GADGET WAIT 0
  354.      {* CLEAN UP *}
  355.      GADGET CLOSE 1
  356.      WINDOW CLOSE 8 
  357.      return
  358.  
  359.  
  360. QUIT_PROGRAM:
  361.      {* CLEAN UP *}
  362.      FOR Counter=255 TO 249 STEP -1
  363.           GADGET CLOSE Counter
  364.      NEXT
  365.      
  366.      WINDOW CLOSE 9
  367.